#include <REGX52.H>

void Delayxms(unsigned int delay){	// ms
	unsigned char i, j;
	while(delay){
	i = 2;
	j = 199;
	do
	{
		while (--j);
	} while (--i);
	delay--;
	}
}

//	P2 = 0xfe;
void main (){
	unsigned int delay = 100;
	while (1){
		if(P3_1 == 0){	//pressed button k1
			Delayxms(10);	//kill the joggle manualy
			while(P3_1 == 0);	//keep (while button is pressed, still in the while ,not go next)
			
			//unpressed the button
			Delayxms(10);	//kill the joggle manualy
			P2_0 = ~P2_0;
		}
	}	
}
